package com.df.bpm.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaIgnore;
import com.df.bpm.dto.BusinessInformationDTO4Subset;
import com.df.bpm.service.impl.BusinessInformationDTO4SubsetServiceImpl;
import com.df.common.utils.CommonUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 业务大全控制器
 */
@Slf4j
@Tag(name = "业务大全控制器")
@RequestMapping("/businessInformationDTO4Subset")
@RequiredArgsConstructor
@RestController
@SaCheckLogin
public class BusinessInformationDTO4SubsetController {
    /**
     * 业务信息服务
     */
    public final BusinessInformationDTO4SubsetServiceImpl businessInformationDTO4SubsetServiceImpl;

    /**
     * 获取业务信息
     * @param superior 上级业务信息 -1=根
     * @param groupID 上级业务信息 -1=不分组
     */
    @Operation(summary = "获取业务信息", description = "获取业务信息")
    @GetMapping("getSteps")
    @SaIgnore
    public ResponseEntity<List<BusinessInformationDTO4Subset>> getSteps(@RequestParam(required = false) Integer groupID, @RequestParam Integer superior) {
        if (CommonUtils.varIsBlank(groupID)){
            groupID = null;
        }
        if (CommonUtils.varIsBlank(superior)){
            superior = -1;
        }
        return ResponseEntity.ok(businessInformationDTO4SubsetServiceImpl.getSteps(groupID,superior));
    }


}
